package com.woniu.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.apartment.domain.Wish;
import com.woniu.apartment.service.IWishService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户收藏房型和公寓列Controller
 * 
 * @author yy
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/apartment/tbwish")
@Api("用户收藏房型和公寓列管理")
public class WishController extends BaseController
{
    @Autowired
    private IWishService wishService;

    /**
     * 查询用户收藏房型和公寓列列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbwish:list')")
    @GetMapping("/list")
    @ApiOperation("用户收藏房型和公寓列分页查询")
    public TableDataInfo list(Wish wish)
    {
        startPage();
        List<Wish> list = wishService.selectWishList(wish);
        return getDataTable(list);
    }

    /**
     * 导出用户收藏房型和公寓列列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbwish:export')")
    @Log(title = "用户收藏房型和公寓列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("用户收藏房型和公寓列导出")
    public void export(HttpServletResponse response, Wish wish)
    {
        List<Wish> list = wishService.selectWishList(wish);
        ExcelUtil<Wish> util = new ExcelUtil<Wish>(Wish.class);
        util.exportExcel(response, list, "用户收藏房型和公寓列数据");
    }

    /**
     * 获取用户收藏房型和公寓列详细信息
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbwish:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询用户收藏房型和公寓列")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wishService.selectWishById(id));
    }

    /**
     * 新增用户收藏房型和公寓列
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbwish:add')")
    @Log(title = "用户收藏房型和公寓列", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加用户收藏房型和公寓列")
    public AjaxResult add(@RequestBody Wish wish)
    {
        return toAjax(wishService.insertWish(wish));
    }

    /**
     * 修改用户收藏房型和公寓列
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbwish:edit')")
    @Log(title = "用户收藏房型和公寓列", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新用户收藏房型和公寓列")
    public AjaxResult edit(@RequestBody Wish wish)
    {
        return toAjax(wishService.updateWish(wish));
    }

    /**
     * 删除用户收藏房型和公寓列
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbwish:remove')")
    @Log(title = "用户收藏房型和公寓列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除用户收藏房型和公寓列")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wishService.deleteWishByIds(ids));
    }
}
